<%@ page import = "java.util.Hashtable,
                   ro.xblue.translator.LanguageBean,
                   ro.gateway.aida.servlet.*,
                   ro.gateway.aida.obj.*,
                   ro.xblue.translator.TranslatorUtils,
                   java.util.ArrayList,
                   ro.gateway.aida.fnd.FundingItem,
                   ro.gateway.aida.admin.ActivityObjectsOptions,
                   ro.gateway.aida.admin.ActObjsOptsConst" %>
<%@ taglib uri="/WEB-INF/taglib.tld" prefix="gtw" %>
<%@ taglib uri="/WEB-INF/translator.tld" prefix="trans" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/usr.tld" prefix="usr" %>
<%
      Object screen = request.getAttribute(EditActivityServlet.PNAME_SCREEN);
      String key = (String) request.getAttribute(EditActivityServlet.PNAME_KEY);
      if ((request.getAttribute(EditActivityServlet.SIGNATURE) == null) || (key == null)) return;

//      System.err.println("Screen:" + screen);
//      System.err.println("Key:" + key);
      Hashtable ed_ctx = (Hashtable) request.getAttribute(EditActivityServlet.PNAME_R_CTX);
      LanguageBean lang_bean = TranslatorUtils.getCurrentLanguage(request, application);
      String lang=lang_bean.language;
      Activity bean = (Activity) ed_ctx.get(EditActivityServlet.PNAME_BEAN);
		String ctx = request.getContextPath();
      String title = bean.getTitle(lang_bean.language);
      if (title == null) title = "";

      OrganizationInv[] fin_orgs = bean.getOrgsByLRId(OrganizationRole.FINANCING_ORG_ROLE);
      if (fin_orgs == null) fin_orgs = new OrganizationInv[0];
      PersonInv[] fin_pers = bean.getPersonsByLRId(OrganizationRole.FINANCING_ORG_ROLE);
      if (fin_pers == null) fin_pers = new PersonInv[0];

      ActivityObjectsOptions aoo = ActivityObjectsOptions.getInstance();
%>
<trans:initPage module="prj_pages" />
<gtw:get_errors/>
<html>
<head>
<link rel="shortcut icon" href="<html:rewrite page="/images/lpd.png"/>" type="image/ico" />
 <META HTTP-EQUIV="EXPIRES" CONTENT="0"> 
  <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
<title>Local Projects Database - Project Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="alf.css" type="text/css">
<STYLE>.text_searchbold {
	FONT-WEIGHT: bold; FONT-SIZE: 8pt; COLOR: #000000; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif
; text-decoration: none}
.text_search {
	FONT-SIZE: 8pt; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.text {
	FONT-WEIGHT: normal; FONT-SIZE: 9pt; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
.titlu {
	FONT-WEIGHT: bold; FONT-SIZE: 11pt; FONT-STYLE: normal; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none
}
A:hover {
	TEXT-DECORATION: underline
}
</STYLE>
<script language="javascript">
 function help(pageName) {
        ed_donor_orgs_win = window.open(
        "<%=ctx%>/help/UserGuide.pdf",
        "ed_fin_win", "HEIGHT=500,WIDTH=700");

    };
	</script>


<script language="javascript">
    var ed_rel_win;
    function open_rel() {
          var open_arg = "HEIGHT=420,WIDTH=550,SCROLLBARS=YES,LEFT=" +
               (window.screen.availWidth - 550) / 2 + ",TOP=" +
               (window.screen.availHeight - 420) / 2;
          ed_rel_win = window.open(
          "activity/selector.do",
          "ed_selector_win", open_arg);
    };
    function after_prj_sel() {
        document.theform.after_selector.value = 'proiect';
        real_submit();
    };
    var ed_fin_orgs_win;
    var ed_fin_pers_win;
    function add_fin(org_id) {
          var open_arg = "HEIGHT=520,WIDTH=650,SCROLLBARS=YES,LEFT=" +
               (window.screen.availWidth - 650) / 2 + ",TOP=" +
               (window.screen.availHeight - 520) / 2;
          wed_funditems = window.open(
          "fnd2/editor.do?action=new&key=<%=key%>&org_id=" + org_id,
          "ed_fnd_win", open_arg);
    }
    function edit_fin(org_id, index) {
          var open_arg = "HEIGHT=520,WIDTH=650,SCROLLBARS=YES,LEFT=" +
               (window.screen.availWidth - 650) / 2 + ",TOP=" +
               (window.screen.availHeight - 520) / 2;
          wed_funditems = window.open(
          "fnd2/editor.do?action=edit&key=<%=key%>&org_id=" + org_id + "&item_idx=" + index,
          "ed_fnd_win", open_arg);
    }
    function delete_fin(forma,org_id,item_idx) {
      forma.action.value = "remove_fin_items";
      forma.forg_id.value=org_id;
      forma.fitem_idx.value=item_idx;
      forma.submit();
    }
    function open_fin_pers() {
        <% if (fin_orgs.length > 0) { %>
        ed_fin_pers_win = window.open("pers/selector.do?",
        "ed_con_win", "HEIGHT=400,WIDTH=500,scrollbars=yes");
        <% } else { %>
        alert('<trans:showPageMessage label="p3.err.sfinstf" />');
        <% } %>
    };
    function after_pers_sel() {
        document.theform.after_selector.value = 'pers';
        real_submit();
    }
    function open_fin_orgs() {
        ed_fin_orgs_win = window.open(
        "org/selector.do",
        "ed_fin_win", "HEIGHT=400,WIDTH=500,scrollbars=yes");
    };
    function after_org_sel() {
        document.theform.after_selector.value = 'orgs';
        real_submit();
    };
    function real_submit() {
        document.theform.action.value = '<%=EditActivityServlet.ACTION_SUBMIT%>';
        document.theform.submit();
    };
    var wed_funditems;
    function after_add_fitem(caz) {
        wed_funditems.close();
        if (caz == 0) {
            document.theform.action.value = '<%=EditActivityServlet.ACTION_SUBMIT%>';
            document.theform.after_funding.value="true";
            document.theform.submit();
        }
    }
      function refresh() {
            window.location.reload();
      }
</script>
 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
</head>

<body bgcolor="#FFFFFF" text="#000000" topmargin=0 leftmargin=0>
<jsp:include page="header.jsp" /><br><div align=center class=text_bold><trans:showPageMessage label="p.proiect00" /></div><div align=left class=text_search>&nbsp;&nbsp;&nbsp;<trans:showPageMessage label="p.proiect01" /></div>
  <table width="98%" border="0" cellspacing="1" cellpadding="4" class="text_searchBold" background=images/pixelbgtable.gif align="center">
    <tr>
      <td bgcolor="#FFFFFF" class="text_searchBold" width="30%">
          <table width="100%" cellpadding="0" cellspacing="0" border="0">
               <tr>
                    <td class="text_searchBold" width="10%">
<trans:showPageMessage label="p.editor" /></td><td>
<usr:logged_user cellClass="text_search" showLoginLink="false" /></td>
               </tr>
          </table>
      </td>
      <td background=images/pixelbgtable.gif width=30%>
        <div align="center" class="textalb"><trans:showPageMessage label="p.proiect" /></div>
      </td>
      <td bgcolor="#FFFFFF">
        <div align="center"><a href="org/edit" class="text_searchBold"><trans:showPageMessage label="p.organiz" /></a></div>
      </td>
  </tr>
  </table>

  <table width="98%" border="0" cellspacing="1" cellpadding="5" background=images/pixelbgtable.gif align=center>
    <tr bgcolor="#FFFFFF">
      <td align="center" width="75%" class="textalb" background=images/pixelbgtable.gif>
<trans:showPageMessage label="p.page3" />
      </td>
      <td width="25%" class="text_searchBold" background=images/pixelbgtable.gif>&nbsp;

      </td>
    </tr>
<form name="theform" method="post" action="editActivity">
<input type="hidden" name="prj_jump" value="" />
<input type="hidden" name="action" value="<%=EditActivityServlet.ACTION_SUBMIT%>" />
<input type="hidden" name="key" value="<%=key%>" />
<input type="hidden" name="page" value="3" />
<input type="hidden" name="after_selector" value="" />
<input type="hidden" name="after_funding" value="" />
<input type="hidden" name="delfitems" value="" />
<input type="hidden" name="preview_data" value="false" />
    <tr bgcolor="#FFFFFF">
      <td width="75%" bgcolor="f9f9f9" class="text_search" valign="top">


      <% if (aoo.isEnabled(ActObjsOptsConst.FUNDING_ORGS)) { %>
      <input type="hidden" name="forg_id" value="" />
      <input type="hidden" name="fitem_idx" value="" />
      <br>
      <p><img src=images/arrow_blue.gif hspace=4><b><trans:showPageMessage label="p3.listfin" />
      <%=(aoo.isMandatory(ActObjsOptsConst.FUNDING_ORGS)) ? "(<font color=red>*</font>)" : ""%>
      </b></p>
      <gtw:show_error label='<%=ActObjsOptsConst.FUNDING_ORGS%>' /><br>
      <gtw:show_error label='<%=ActObjsOptsConst.FUNDING_ITEMS%>' />

        <div align="left">
            <% if (fin_orgs.length > 0) for (int i = 0; i < fin_orgs.length; i++) { %>
            <input type="checkbox" name="selected_forg" value="<%=fin_orgs[i].getOrg_id()%>">
            <b>
              <a href=# onclick="javascript:window.open('org/view?id=<%=fin_orgs[i].getOrg().getId()%>', 'org_viewer', 'status=yes,WIDTH=400,HEIGHT=400,scrollbars=YES');">
<%=fin_orgs[i].getOrg().getName()%></a>
</b><br><br>
                  <% ArrayList fnd_items = bean.
                        getFndItemsForOrg(fin_orgs[i].getOrg_id()); if (fnd_items == null) fnd_items = new ArrayList();%>
                  <center>
                  <table width="80%" cellpadding="5" border="0" cellspacing="0">
                  <tr>
                        <td colspan="2">
                        <% for (int j = 0; j < fnd_items.size(); j++) { FundingItem item=( FundingItem ) fnd_items.get(j);%>
                        <table width="100%" border="1" cellpadding="0" cellspacing="0" class=text_search><tr><td>
                              <% request.setAttribute("funding_item", item); %>
                              <% request.setAttribute("feditable", "true");%>
                              <% request.setAttribute("fitem_edit_js_call", "edit_fin(" + fin_orgs[i].getOrg_id() + "," +
                                    + j + ");");%>
                              <% request.setAttribute("fitem_delete_js_call", "delete_fin(theform, " + fin_orgs[i].getOrg_id() + "," +
                                    + j + ")");%>
                              <jsp:include page="/fnd2/funding_displayer.jsp" />
                        </td></tr></table>
                        <br>
                        <% } %>
                        </td>
                  </tr>
                  <tr>
                        <td colspan="2" align="left">
                        <input type="button" class="buton" value="<trans:showPageMessage label="p3.addfunding" hide_link="true" />"
                              onclick="add_fin('<%=fin_orgs[i].getOrg_id()%>');" />
                        </td>
                  </tr>
                  </table>
                  </center>
                  <br><br>
            <% } %>

            <!-- submitari -->
            <input onClick="javascript:open_fin_orgs();" class="buton" type="button" value="<trans:showPageMessage label="p3.addorg" hide_link="true" />" />
            <% if (fin_orgs.length > 0) { %>
            <input type="button" name="remove_fin_orgs" class="buton" value="<trans:showPageMessage label="p.remove_fin_orgs" hide_link="true" />"
            onclick="javascript:document.theform.action.value='remove_fin_orgs';document.theform.submit();">
            <% } %>
        </div><br>
      <% } %>

	<% if (aoo.isEnabled(ActObjsOptsConst.FUNDING_PERSONS)) { %>
	<gtw:show_error label='<%=ActObjsOptsConst.FUNDING_PERSONS%>' />
	<p><img src=images/arrow_blue.gif hspace=4><b><trans:showPageMessage label="p3.labelpers" /></b> </p>
	<div align="center">
	<table width="80%" cellpadding="5" border="0" cellspacing="1" background=images/pixelbgtable.gif>
		<tr>
		<td class="text_searchbold" bgcolor="#FFFFFF"><trans:showPageMessage label="p4.listpers" />
			<%=aoo.isMandatory(ActObjsOptsConst.FUNDING_PERSONS) ? "(<font color=red>*</font>)" : ""%>
		</td>
		</tr>
		<tr>
		<td class="text_search" bgcolor="#FFFFFF">
			<% if (fin_pers.length == 0) { %>
			<trans:showPageMessage label="p4.nopers" />
			<% } else { %>
			<% for (int i = 0; i < fin_pers.length; i++) { %>
			<input type="checkbox" name="finpers_id" value="<%=fin_pers[i].getPerson_id()%>" />
			<a href=# onclick="javascript:window.open('pers/view?id=<%=fin_pers[i].getPerson().getId()%>', 'pers_viewer', 'status=yes,WIDTH=400,HEIGHT=400,SCROLLBARS=yes');">
			<%=fin_pers[i].getPerson().getName()%></a><br>
			<% } %>
			<% } %>
		</td>
		</tr>
		<tr>
		<td bgcolor="#FFFFFF">
			<input onClick="javascript:open_fin_pers();" class="buton" type="button" value="<trans:showPageMessage label="p4.edpers" hide_link="true" />" />
			<% if (fin_pers.length > 0) { %>
			<input type="button" name="remove_fin_pers" class="buton" value="<trans:showPageMessage label="p.remove_fin_pers"  hide_link="true" />"
			onclick="javascript:document.theform.action.value='remove_fin_pers';document.theform.submit();">
			<% } %>
		</td>
		</tr>
	</table>
	</div>
	<% } %>

        <% if (aoo.isEnabled(ActObjsOptsConst.ACT_RELATIONS)) { %>
        <script language="javascript">
            function del_rel(forma) {
                  var first = 1;
                  if (forma.rprj_id.length) {
                        for (var i = 0; i < forma.rprj_id.length; i++) {
                              if (forma.rprj_id[i].checked) {
                                    if (first == 1) {
                                          first = 0;
                                          break;
                                    }
                              }
                        }
                        if (first == 1) {
                              alert('Select project and try again');
                              return;
                        }
                  } else {
                        if (!forma.rprj_id.checked) {
                              alert('Select project and try again');
                              return;
                        }
                  }
                  forma.action.value = 'remove_relations';
                  forma.submit();
            }
        </script>
      <gtw:show_error label='<%=ActObjsOptsConst.ACT_RELATIONS%>' />
        <p><b><img src=images/arrow_blue.gif hspace=4><trans:showPageMessage label="md.prel" /></b>
            <%=(aoo.isMandatory(ActObjsOptsConst.ACT_RELATIONS)) ? "(<font color=red>*</font>)" : ""%>
        </p>
        <div align="center">
        <table width="80%" cellpadding="5" border="0" cellspacing="1" background=images/pixelbgtable.gif>
          <tr>
            <td class="text_searchbold" bgcolor="#FFFFFF"><trans:showPageMessage label="p3.listprel" /></td>
        </tr>
        <%
             ActivityRelation[] relations = bean.getAct_relationsArray();
             if (relations == null) relations = new ActivityRelation[0];
//'1','2','3','4'
//1 = relatedTo activity is part of this activity
//2 = this activity is part of the relatedTo activity
//3 = relatedTo activity continued this activity
//4 = this activity continued the relatedTo activity
             String[] s_relations = new String[] {
                  "is part of this activity",
                  "is parent for this activity",
                  "continued this activity",
                  "was continued by this activity"
             };

             String[] relation_codes = new String[] {
                  "child_of", "parent_of", "before", "after"
             };
        %>
        <% if (relations.length != 0) { %>
          <% for (int i = 0; i < relations.length; i++) { %>
               <tr>
                    <td class="text_search" bgcolor="#FFFFFF">
                        <input type="checkbox" name="rprj_id" value="<%=relations[i].getRelto_activity_id()%>" />
                         <%=relations[i].getRelToTitle().getName(lang_bean.language)%>:
                         <select name="relation<%=relations[i].getRelto_activity_id()%>">
                         <% for (int j = 0; j < s_relations.length; j++) { %>
                         <option <%=((j == 0) && (relations[i].getRelation() == null)) || relation_codes[j].equals(relations[i].getRelation()) ? "selected=\"true\" " : ""%>value="<%=relation_codes[j]%>"><trans:showPageMessage hide_link="true" label='<%=relation_codes[j]%>' /></option>
                         <% } %>
                         </select><br/>
					<trans:showPageMessage label="translator.showhiddentags" />
                    <br>
                    </td>
               </tr>
          <% } %>
        <% } else { %>
          <tr>
               <td class="text_search" bgcolor="#FFFFFF"><trans:showPageMessage label="p3.noprel" /></td>
          </tr>
        <% } %>
        <tr>
            <td bgcolor="#FFFFFF">
                  <input type="button" class="buton" name="dmat1"
                  value="<trans:showPageMessage label="p3.edprel" hide_link="true" />"
                  onclick="javascript:open_rel();" />
                  <input type="button" class="buton" name="dmat2"
                  value="<trans:showPageMessage label="p3.delprel" hide_link="true" />"
                  onclick="javascript:del_rel(this.form);" />
            </td>
        </tr>
        </table>
        </div>
    <br><br>
    <% } // RELATIONS ENABLED%>

        <div align="center">
          <input type="button" name="un_nume" value="<trans:showPageMessage label="p.sinfo" hide_link="true" />" onClick="javascript:document.theform.action.value='<%=EditActivityServlet.ACTION_SUBMIT%>';document.theform.submit();" class="butonsave"/>
        </div>
      </td>
      <td width="25%" valign="top">
<!-- meniu dreapta -->
      <table width="98%" border="0" cellspacing="1" cellpadding="2" bgcolor="#000066">
        <tr>
	      <td bgcolor="#000066" align="center"><b> <span class="textalb"><trans:showPageMessage label="p.proj" />:</span>
            <span class="textalb"><font color="#F9E031"><%=title%></font></span></b></td>
</tr>
<tr>
	<td background=images/pixelbgtable.gif class="textalb">
		<img src=images/arrow_white_tr.gif>
		<a
            onclick="javascript:theform.prj_jump.value='1';theform.submit();"
            style="cursor:hand;"
            class="textalb"><trans:showPageMessage label="md.identif" /></a>
	</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='1';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.plan" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='2';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.loc" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='2';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.sec" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='2';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.comp" /></a>
</td>
</tr>
<tr>
          <td bgcolor="#336699" class="textalb"> <img src=images/arrow_white_tr.gif> <a href="editActivity?key=<%=key%>&page=3" class="textalb"><trans:showPageMessage label="md.fin" /></a>
          </td>
</tr>
<tr>
          <td bgcolor="#336699" class="textalb"> <img src=images/arrow_white_tr.gif> <a href="editActivity?key=<%=key%>&page=3" class="textalb"><trans:showPageMessage label="md.prel" /></a>
          </td>
</tr>

<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='4';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.cauth" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='5';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.ben" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='5';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.descobj" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='6';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.docl" /></a>
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='6';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="md.pinv" /></a>
</td>
</tr>
<% if (aoo.isEnabled(ActObjsOptsConst.NOTEFIELDS)) { %>
<tr>
<td background=images/pixelbgtable.gif class="textalb">
	<img src=images/arrow_white_tr.gif>
	<a
      onclick="javascript:theform.prj_jump.value='7';theform.submit();"
      style="cursor:hand;"
      class="textalb"><trans:showPageMessage label="p.notefields" /></a>
</td>
</tr>
<% } %>
<tr>
<td background=images/pixelbgtable.gif align="center">
<input type="button" name="Help" class="buton" value="<trans:showPageMessage label="p.help" hide_link="true" />"
          onClick="javascript:help('aboutPage1.htm');">
</td>
</tr>
<tr>
<td background=images/pixelbgtable.gif height="45">
<div align="center">
<input	type="button" onclick="javascript:document.theform.action.value='<%=EditActivityServlet.ACTION_SUBMIT%>';document.theform.preview_data.value='true';document.theform.submit();"
	value='<trans:showPageMessage label="p.pubinfo" hide_link="true" />'
	class="butonpublish"
/><trans:showPageMessage label="translator.showhiddentags"/>
</div>
</td>
</tr>
</table>
<!-- ziendof meniu dreapta -->
      </td>
    </tr>
  </table>
</form>

<script language="javascript">
function chlang(dd) {
if(dd.options[dd.selectedIndex].value == 'ro') window.location='/editActivity?lang=ro';
if(dd.options[dd.selectedIndex].value == 'us') window.location='/editActivity?lang=us';
}
</script>
<jsp:include page="footer.jsp" />
</body>
 <HEAD> 
 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
 </HEAD> 
</html>
<!--
-->